import rclpy
from rclpy.node import Node
from base_interfaces.srv import Addints

class AddintsServer(Node):
    def __init__(self):
        super().__init__("addints_server_node_py")
        self.get_logger().info("创建了服务端节点")
        self.server=self.create_service=(Addints,"addints",self.add)
        self.get_logger().info("服务端启动")
    def add(self,request,response):
        response.sum=request.num1 + request.num2
        self.get_logger().info("%d + %d = %d" % (request.num1,request.num2,response.sum))
        return response


def main():
    rclpy.init()
    rclpy.spin(AddintsServer())
    rclpy.shutdown()

if __name__ == '__main__':
    main()
